lexographically smallest equivalent string